package com.csq.manager.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csq.manager.pojo.Enterprise;
import com.csq.manager.service.CompanyService;

@Controller
@RequestMapping("/manager/company")
public class CompanyController {

	@Autowired
	private CompanyService companyService;

	@RequestMapping(value = "/{enterpriseId}")
	@ResponseBody
	public Enterprise getEnterpriseByID(@PathVariable Integer enterpriseId) {
		System.out.println("sasas");
		Enterprise enterprise = companyService.getEnterpriseByID(enterpriseId);

		System.out.println("sasas");
		return enterprise;
	}

	@RequestMapping(value = "/list/type/{typeId}")
	public String getAllEnterpriseList(HttpServletRequest request,
			@PathVariable Integer typeId) {
		List<Enterprise> allEnterpriseList = companyService
				.getAllEnterpriseList(typeId);
		request.setAttribute("allEnterpriseList", allEnterpriseList);
		System.out.println("/list/type/" + typeId);
		return "/manager/user/company";
	}
}
